package com.zoe.app.controller;

import cn.hutool.extra.servlet.ServletUtil;
import com.zoe.app.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author zbg
 * @date 2023/06/06
 * @description
 */
@RestController
@RequiredArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @GetMapping
    public void calc() {

        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        String clientIP = ServletUtil.getClientIP(requestAttributes.getRequest());
        System.out.println(clientIP);
        orderService.calcOrder();
    }
}
